package com.woniuxy.stall.web.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.core.util.PageInfo;
import com.woniuxy.core.model.Result;
import com.woniuxy.stall.model.Param.PassStallCheckParam;
import com.woniuxy.stall.model.Param.loadAllStallCheckParam;
import com.woniuxy.stall.model.dto.StallCheckDto;
import com.woniuxy.stall.model.form.loadAllStallCheckForm;
import com.woniuxy.stall.model.form.PassStallCheckForm;
import com.woniuxy.stall.service.StallCheckService;
import com.woniuxy.stall.service.StallInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 凌玉春
 * @since 2024年01月15日
 */
@RestController
@RequestMapping("/stallCheck")
@Api(tags = "车位申请接口")
public class StallCheckController {

    @Resource
    private StallCheckService stallCheckService;

    @ApiOperation("物业查询所有申请表")
    @PostMapping("loadAllStallCheck")
    public Result<PageInfo> loadAllStallCheck(@RequestBody loadAllStallCheckForm lsf){
        loadAllStallCheckParam param = BeanUtil.toBean(lsf, loadAllStallCheckParam.class);
        PageInfo<StallCheckDto> pageInfo = stallCheckService.loadAllStallCheck(param);
        return Result.getResult(PageInfo.class).setMessage("加载所有车位申请表成功").setData(pageInfo);
    }


    @ApiOperation("物业通过出租客申请的车位")
    @PostMapping("passStallCheck")
    public Result passStallCheck(@RequestBody PassStallCheckForm psf){
        PassStallCheckParam param = BeanUtil.toBean(psf, PassStallCheckParam.class);
        stallCheckService.passStallCheck(param);
        return Result.getResult().setMessage("成功通过");
    }

    @ApiOperation("物业驳回出租客申请的车位")
    @GetMapping("/rejectStallCheck")
    @ApiImplicitParam(name = "stallCheckId",value = "申请车位id")
    public Result rejectStallCheck(Integer stallCheckId){
        stallCheckService.rejectStallCheck(stallCheckId);
        return Result.getResult().setMessage("驳回成功");
    }

}

